//
//  SDMessageItemCell.m
//  SKinDiary
//
//  Created by pcyang on 16/7/26.
//  Copyright © 2016年 tencent. All rights reserved.
//

#import "SDMessageItemCell.h"


#define kLeftMarginWidth             (23.f)
#define kRightSpace             (10.f)
#define kImgToNameSpace         (20.f)

@interface SDMessageItemCell ()

@property(nonatomic,strong) UILabel  *creationTimeLabel;
@property(nonatomic,strong) UILabel  *contentLabel;

@end


@implementation SDMessageItemCell
-(id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self)
    {

        _creationTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(kLeftMarginWidth, 26, kScreenWidth- 2*kLeftMarginWidth, 15)];
        [_creationTimeLabel setFont:[UIFont systemFontOfSize:13.f]];
        [_creationTimeLabel setTextColor:[UIColor colorWithRGB:0xb4bec8]];
        [self.contentView addSubview:_creationTimeLabel];
        
        _contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(_creationTimeLabel.left, _creationTimeLabel.bottom + 8, kScreenWidth  - 2*kLeftMarginWidth, 13)];
        _contentLabel.numberOfLines  = 2;
        [_contentLabel setFont:[UIFont systemFontOfSize:13.f]];
        [_contentLabel setTextColor:[UIColor colorWithRGB:0x747f8b]];
        [self.contentView addSubview:_contentLabel];
        
        UIView* lineBottom = [[UIView alloc] initWithFrame:CGRectMake(kLeftMarginWidth, kMessageCellHeight - 1.f, kScreenWidth - 2*kLeftMarginWidth, 1.f)];
        lineBottom.backgroundColor = RGB(0xf3, 0xf4, 0xf4);
        [self.contentView addSubview:lineBottom];
    }
    
    return self;
}

-(void)setCellData:(SDMessageItem*)infoItem
{
    [_creationTimeLabel setText:infoItem.CreatedAt];
    [_creationTimeLabel sizeToFit];

    _contentLabel.text = infoItem.MessageContent;
    [_contentLabel sizeToFit];
}
@end
